<%@ page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
 <div id="dg" region="center" style="padding:1px;">
  <t:datagrid name="cbsDelinerList" checkbox="true" fitColumns="false" title="发货管理" actionUrl="cbsDelinerController.do?userDatagrid"
               idField="id" fit="true" queryMode="group" onLoadSuccess="changeColor">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="发货单号"  field="code"    queryMode="single" query="true"  width="120"></t:dgCol>
    <t:dgCol title="发货单类型"  field="deliverType"    queryMode="single" dictionary="<%= StaticValue.Deliver_Type %>" width="80" sortable="true"></t:dgCol>
   <t:dgCol title="发货状态"  field="status"    queryMode="single"  width="100" sortable="true" dictionary="<%= StaticValue.Deliver_State1%>" query="true"></t:dgCol>
   <t:dgCol title="备件申请单号"  field="recordId"  hidden="true"  queryMode="single" width="120"></t:dgCol>
   <t:dgCol title="CR"  field="crCode"    queryMode="single" query="true" width="120" ></t:dgCol>
   <t:dgCol title="SO"  field="soCode"    queryMode="single"  width="120" query="true"></t:dgCol>
         <t:dgCol title="SR"  field="srCode"   queryMode="single"  width="75" query="true" ></t:dgCol>
   <t:dgCol title="影院名称"  field="cinemaName" query="true"   queryMode="single"  width="180"></t:dgCol>
   <t:dgCol title="所属省市"  field="territoryName" hidden="true"  query="true"  queryMode="single"  width="120" ></t:dgCol>
   <t:dgCol title="省"  field="shengName"    queryMode="single"  width="120" ></t:dgCol>
   <t:dgCol title="市"  field="shiName"    queryMode="single"  width="120" ></t:dgCol>
   <t:dgCol title="备件类型"  field="typeDesc"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="修改到货时间原因"  field="changeTimeReason" hidden="true" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="数量"  field="total"    queryMode="single"  width="80"></t:dgCol>
   <t:dgCol title="SLA"  field="fhSLA"    queryMode="single" query="true" dictionary="<%= StaticValue.Deliver_SLA %>"  width="60" sortable="true"></t:dgCol>
   <t:dgCol title="CSA派单时间"  field="CSASendTime"  query="true"   queryMode="group"  width="130"></t:dgCol>
   <t:dgCol title="发货时间"  field="logisticsSendTime"  query="true"   queryMode="group"  width="130"></t:dgCol>
   <t:dgCol title="预计到货时间"  field="expectTime"    queryMode="single"  width="130"></t:dgCol>
   <t:dgCol title="签收时间"  field="getTime"  query="true"  queryMode="group"  width="130"></t:dgCol>
   <t:dgCol title="SLA未达标"  field="isStandard"    queryMode="single" query="true" dictionary="<%= StaticValue.Deliver_Standard %>"  width="70"></t:dgCol>
   <t:dgCol title="ETA延迟"  field="etaStandard"    queryMode="single" query="true" dictionary="<%= StaticValue.ETA_STANDARD %>"  width="70"></t:dgCol>
   <t:dgCol title="签收延迟"  field="signStandard"    queryMode="single" query="true" dictionary="<%= StaticValue.SIGN_STANDARD %>"  width="70"></t:dgCol>
   <t:dgCol title="未达标原因"  field="notQualified"  hidden="true"   queryMode="single"   width="120"></t:dgCol>

   <%--<t:dgCol title="申请优先级"  field="applyLayer"  hidden="true" dictionary="<%= StaticValue.apply_layer %>"  queryMode="single"  width="120"></t:dgCol>--%>
   <t:dgCol title="物流"  field="deliverLogistics" hidden="true"   queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创单时间"  field="createDate" hidden="true"   queryMode="single"  width="120" sortable="true"></t:dgCol>
   <t:dgCol title="预计到货时间"  field="expectTime"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="物流时长"  field="logisticsDuration"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="物流单号"  field="logNumber" query="true"   queryMode="single"  width="120"></t:dgCol>
  
   <t:dgCol title="创建人名称"  field="createName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="姓名"  field="userName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="收货人电话"  field="phone"  query="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="详细地址"  field="address"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="备件序列号SN"  field="sn"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人登录名称"  field="createBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人名称"  field="updateName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人登录名称"  field="updateBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新日期"  field="updateDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgToolBar title="物流发货" icon="icon-add"  funname="sendWl"></t:dgToolBar>
   <t:dgToolBar title="物流签收" icon="icon-add"  funname="sendSign"></t:dgToolBar>
   <t:dgToolBar title="查看" icon="icon-search"  funname="addSearchTab"></t:dgToolBar>
   <t:dgToolBar title="修改预计到货时间"  icon="icon-add"  funname="changeTime"></t:dgToolBar>
   <t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
  </t:datagrid>
 </div>
</div>`
<script src = "webpage/com/zybk/com.deli/cbsDelinerList.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        //给时间控件加上样式
        $("#cbsDelinerListtb").find("input[name='CSASendTime_begin']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
        $("#cbsDelinerListtb").find("input[name='CSASendTime_end']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
        $("#cbsDelinerListtb").find("input[name='logisticsSendTime_begin']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
        $("#cbsDelinerListtb").find("input[name='logisticsSendTime_end']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
        $("#cbsDelinerListtb").find("input[name='getTime_begin']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
        $("#cbsDelinerListtb").find("input[name='getTime_end']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});


        territoryLink("cbsDelinerList","territoryName");
    });
    function sendWl() {
        var datas = $("#cbsDelinerList").datagrid("getSelections");
        if(datas.length != 1){
            tip("请选择一条信息");
            return;
        }
        var status = datas[0].status;
        if (status==6){
            tip("该单已发货");
            return false;
        }
        if (status==7){
            tip("该单已签收");
            return false;
        }
        var id = datas[0].id;
        addOneTab('物流发货', 'cbsDelinerController.do?sendLogistics&id='+id, '');
    }
    function changeTime() {
        var datas = $("#cbsDelinerList").datagrid("getSelections");
        if(datas.length != 1){
            tip("请选择一条信息");
            return;
        }
        var id = datas[0].id;
        var status = datas[0].status;
        if (status<6){
            tip("请先发货");
            return false;
        }
        if (status==7){
            tip("该单已签收");
            return false;
        }
        var changeTimeReason = datas[0].changeTimeReason;
        if (changeTimeReason!=null&&changeTimeReason!=""){
            tip("只能修改一次预计到货时间");
            return false;
        }
        addOneTab('物流发货', 'cbsDelinerController.do?sendLogistics&reason=XG&id='+id, '');
    }
    function sendSign() {
        var datas = $("#cbsDelinerList").datagrid("getSelections");
        if(datas.length != 1){
            tip("请选择一条信息");
            return;
        }
        var id = datas[0].id;
        var status = datas[0].status;
        if (status<6){
            tip("请先发货");
            return false;
        }
        if (status==7){
            tip("该单已签收");
            return false;
        }
        addOneTab('物流签收', 'cbsDelinerController.do?sendSign&id='+id, '');
    }

    function addSearchTab(){
        var datas = $("#cbsDelinerList").datagrid("getSelections");
        var status = datas[0].status;
        if(datas.length != 1){
            tip("请选择一条发货单");
            return;
        }
        var id = datas[0].id;
        if (status==7){
            addOneTab("物流签收","cbsDelinerController.do?sendSignDetails&reason=sign&id="+id,"");
        }else {
            addOneTab("物流发货","cbsDelinerController.do?sendDetails&reason=send&id="+id,"");
        }

    }


    //已签收的发货单,未达标且没有填写未达标原因的记录高亮显示
    //     $('#cbsDelinerList').datagrid({
    //         rowStyler:function(index,row){
    //             if (row.status=='7' && row.isStandard=='2'&& row.notQualified==""){
    //                         return 'background-color:red;';
    //                         //return 'background:#e9faff;';
    //                 }
    //             }
    //                /* styler: function(value,row,index){
    //                     if (row.status=='7' && row.isStandard=='2'&& row.notQualified=="" && value=="code"){
    //                         return 'background-color:#ffee00;color:red;';
    //                     }
    //                 }*/
    //     });




    //导入
    function ImportXls() {
        openuploadwin('Excel导入', 'cbsDelinerController.do?upload', "cbsDelinerList");
    }

    //导出
    function ExportXls() {
        var currPageRows = $("#cbsDelinerList").datagrid("getRows");
        var idsData = [];
        $(currPageRows).each(function (i, rowData) {
            idsData.push(rowData.id);
        });
        if (idsData.length > 0) {
            myDownload("cbsDelinerController.do?exportXlsForLogistics", "deliverIds=" + idsData.join(","));
        } else {
            tip("当前页面没有数据可以导出");
        }
    }

    //模板下载
    function ExportXlsByT() {
        JeecgExcelExport("cbsDelinerController.do?exportXlsByT","cbsDelinerList");
    }
    function changeColor() {
        var trs = $("#cbsDelinerList").prev().find('div.datagrid-body').find('tr');
        for (var i = 0; i < trs.length; i++) {

            for (var j = 0; j < 20; j++) {

                if (trs[i].cells[j].firstChild.innerHTML =='Y' ){
                    trs[i].cells[j].style.cssText = 'color:red';
                }
            }
        }
    }
</script>